<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<%--获取当前时间--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="java.sql.*" %>
<%@ page import="com.mysql.jdbc.StringUtils" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.HashMap" %>
<jsp:useBean id="now" class="java.util.Date" scope="page"/>
<fmt:formatDate var="nowTime" value="${now}" pattern="yyyy-MM-dd HH:mm:ss"/>
<!DOCTYPE html>
<html>

<!--导航条 start-->


<%

    request.setCharacterEncoding("utf-8");
 //收藏最多排行
    Connection conn = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    String hotSql = "select identity from car order by collection desc";
    PreparedStatement a1 = conn.prepareStatement(hotSql);
    ResultSet rs1 = a1.executeQuery();
    System.out.println("执行了sql ==>"+hotSql);
    //每日上新
    String newlyCar = "select * from car where to_days(createtime) = to_days(now()); ";
    PreparedStatement a2 = conn.prepareStatement(newlyCar);
    ResultSet rs2= a2.executeQuery();
    System.out.println("执行了sql ==>"+newlyCar);
    //新人代步推荐
    Connection conn2 = DriverManager.getConnection("jdbc:mysql://43.142.239.28:13307/carxianyu?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC","root","root");
    String recommendSql = "select * from car order by price ASC  limit 3";
    PreparedStatement a3 = conn2.prepareStatement(recommendSql);
    ResultSet rs3= a3.executeQuery();
    System.out.println("执行了sql ==>"+recommendSql);
%>






<head>
    <meta charset="utf-8">
    <title>二手汽车平台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctx}/static/layui/style/template.css" media="all">
    <script src="${ctx}/static/layui/layui.js"></script>
    <script>
        var ctx = '${ctx}/';
    </script>
</head>
<body>
<!--导航条 start-->
<jsp:include page="/head.jsp"/>
<!--导航条 start-->


<!--导航条 end-->
<jsp:include page="/banner.jsp"/>



<%--<!--导航条 end-->--%>
<div class="layui-container layadmin-cmdlist-fluid">


    <div class="layui-row layui-col-space30">

<hr/>
            <div>
                <h1 align="center">热门品牌</h1>

                <table align="center" >

                    <%
                        while (rs1.next()){
                            String identity = rs1.getString("identity");

                    %>

                    <tr>
                        <td><h2><%=identity%></h2></td>
                    </tr>
                    <%}
                    %>
                </table>
            </div>

        <hr/>

        <div>
            <h1 align="center">今日上新</h1>
        </div>
        <!--商品图begin-->
        <% while(rs2.next()){

            //为列表参数初始化


            Integer id = rs2.getInt("id");
            String name = rs2.getString("name");
            String images = rs2.getString("images");
            String price = rs2.getString("price");

            String address = rs2.getString("address");
            Integer age =Integer.valueOf( rs2.getString("age"));
            String createtime = rs2.getString("createtime");
            String identity = rs2.getString("identity");
            String phone = rs2.getString("phone");
            String username = rs2.getString("username");
            Integer collection =Integer.valueOf( rs2.getString("collection"));
            Integer gearboxId =Integer.valueOf( rs2.getString("gearbox"));

            String gearbox = null;
            if(gearboxId == 11){
                gearbox = "手动档";
            }else {
                gearbox= "自动档";
            }



        %>

        <div class="layui-col-md4 layui-col-sm6">
            <div class="cmdlist-container">

                <img src="<%=images%>" style="width: 100%;height: 250px;">

                <a href="javascript:;">
                    <div class="cmdlist-text">
                        <p class="info"> <%=name%></p>
                        <div class="price">
                            <b><span style="color: green">$:<%=price%></span></b>
                            <p>作者:<%=username%></p>
                            <span class="flow"><i class="layui-icon layui-icon-date"></i>
                                 <%=createtime.substring(0,10)%>
                                </span>


                        </div>
                    </div>
                </a>
            </div>
        </div>
        <%}%>



        <hr/>

        <div>
            <h1 align="center">新人代步推荐</h1>
        </div>
        <!--商品图begin-->
        <% while(rs3.next()) {

            //为列表参数初始化


            String name = rs3.getString("name");
            String images = rs3.getString("images");
            String price = rs3.getString("price");


            String createtime = rs3.getString("createtime");


            String username = rs3.getString("username");

            Integer gearboxId = Integer.valueOf(rs3.getString("gearbox"));

            String gearbox = null;
            if (gearboxId == 11) {
                gearbox = "手动档";
            } else {
                gearbox = "自动档";
            }



        %>

        <div class="layui-col-md4 layui-col-sm6">
            <div class="cmdlist-container">

                <img src="<%=images%>" style="width: 100%;height: 250px;">

                <a href="javascript:;">
                    <div class="cmdlist-text">
                        <p class="info"> <%=name%></p>
                        <div class="price">
                            <b><span style="color: green">$:<%=price%></span></b>
                            <p>作者:<%=username%></p>
                            <span class="flow"><i class="layui-icon layui-icon-date"></i>
                                 <%=createtime.substring(0,10)%>
                                </span>


                        </div>
                    </div>
                </a>
            </div>
        </div>
        <%}%>




</div>










<%--<!--底部区域 start-->--%>
<div class="layui-footer footer footer-index"
     style="text-align: center;background-color: rgba(0,0,0,0.8);padding: 10px;font-size: 15px;color: #eee;">
    <div class="layui-main">
        <h4>©  二手汽车平台 版权所有</h4>
        <p>
            二手汽车平台 前端页面
        </p>
    </div>
</div>

<!--底部区域 end-->
<style>
    .fl {
        float: left;
    }

    .fr {
        float: right;
    }

    .mb10 {
        margin-bottom: 10px;
    }

    .sideBlock {
        padding: 24px;
    }

    .layui-form-item .layui-input-inline {
        width: auto;
    }

    .layui-input, .layui-select, .layui-textarea {
        height: 30px;
        width: auto;
    }

    .layui-form-label {
        padding: 8px 15px;
    }

    .layui-form-switch {
        height: 34px;
        line-height: 34px;
        margin-top: 0;
        min-width: 54px;
    }

    .layui-form-switch i {
        width: 24px;
        height: 24px;
        top: 5px;
    }

    .layui-form-onswitch i {
        margin-left: -28px;
        top: 5px;
    }

    .layui-form-switch em {
        margin-left: 27px;
    }

    .layui-form-onswitch em {
        margin-left: 5px;
    }

    .layui-btn {
        height: 36px;
    }

    /*修改颜色风格-蓝色 */
    .layui-form-select dl dd.layui-this {
        background-color: #02a7f0;
    }

    .layui-btn-blue {
        background-color: #02a7f0;
    }

    .layui-form-onswitch {
        border-color: #02a7f0;
        background-color: #02a7f0;
    }

    .layui-form-radio > i:hover, .layui-form-radioed > i {
        color: #02a7f0;
    }

    .layui-form-checked[lay-skin=primary] i {
        border-color: #02a7f0;
        background-color: #02a7f0;
    }

    .layui-form-checkbox[lay-skin=primary]:hover i {
        border-color: #02a7f0;
    }
</style>


<script>
    layui.use('carousel', function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
            elem: '#test1'
            , width: '100%' //设置容器宽度
            , arrow: 'always' //始终显示箭头
            //, height:'400px' //设置轮播图高度
            //,anim: 'updown' //切换动画方式
        });
    });
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    var $;
    var layer;
    var element;
    var form;
    layui.use(['element', 'layer', 'jquery', 'form', 'laydate', 'layedit'], function () {
        element = layui.element;
        layer = layui.layer;
        $ = layui.jquery;
        form = layui.form;
        var laydate = layui.laydate;

        //…
    });
</script>

</body>
</html>
